package org.example.myleet.p1202;

import org.example.myleet.Utils.Assert;

import java.util.ArrayList;
import java.util.List;

public class Main {
    public static void main(String[] args) {
        Solution solution = new Solution();
        Assert.isTrue("bacd".equals(solution.smallestStringWithSwaps("dcab", parse(new int[][]{{0,3},{1,2}}))));
        Assert.isTrue("abcd".equals(solution.smallestStringWithSwaps("dcab", parse(new int[][]{{0,3},{1,2},{0,2}}))));
        Assert.isTrue("abc".equals(solution.smallestStringWithSwaps("cba", parse(new int[][]{{0,1},{1,2}}))));
        Assert.isTrue("adbcefbe".equals(solution.smallestStringWithSwaps("bdaefcbe", parse(new int[][]{{0,4},{2,5},{3,4},{4,5},{6,7}}))));
    }

    private static List<List<Integer>> parse(int[][] input) {
        List<List<Integer>> ranges = new ArrayList<>(input.length);
        for (int i=0; i<input.length; i++) {
            List<Integer> range = new ArrayList<>(input[i].length);
            for (int j=0; j<input[i].length; j++) {
                range.add(input[i][j]);
            }
            ranges.add(range);
        }
        return ranges;
    }
}
